import { useState,useEffect } from "react"
import { getchannelAPI } from "@/apis/article"
//封装获取频道的逻辑
function useChannel(){
    //1.获取 频道列表所有的逻辑
//获取频道列表
 //获取频道列表
 const [channeList, setchanneList] = useState([])
 useEffect(() => {
   //1.封装函数 在函数体内调用接口
   const getchannelList = async () => {
     const res = await getchannelAPI()
     setchanneList(res.data.channels)
   }
   //2.调用函数
   getchannelList()
 }, [])
 //2.把组件中要用到的数据return出去
 return{
    channeList
 }
}
export {useChannel}
